<UserControl x:Class="WozLib.UI.Controls.ColorSelector"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WozLib.UI.Controls"
    xmlns:local-util="clr-namespace:WozLib.UI.Util"
    Name="colSelector"
    >
  <UserControl.Resources>
    <DataTemplate DataType="{x:Type local:SelectableColor}">
      <Grid Margin="2">
        <StackPanel Orientation="Horizontal" Margin="4">
          <Rectangle Name="rectColor" MinWidth="8" Height="8" Margin="2,2,2,2" RadiusX="4" RadiusY="4">
            <Rectangle.Fill>
              <SolidColorBrush Color="{Binding Path=Color}" />
            </Rectangle.Fill>
          </Rectangle>
          <TextBlock Margin="5" VerticalAlignment="Center" FontFamily="Verdana" FontSize="12" Foreground="Black" Text="{Binding Path=Description}"/>
        </StackPanel>

      </Grid>
    </DataTemplate>
  </UserControl.Resources>

  <Expander>
    <Expander.Header>
      <StackPanel Orientation="Vertical">
        <StackPanel Orientation="Horizontal">
          <ComboBox x:Name="_InformalColorCombo" MinWidth="80" Margin="5,5,5,5" />
          <Rectangle Name="rectColor" MinWidth="25" Height="25" Margin="5,5,5,5" RadiusX="4" RadiusY="4">
            <Rectangle.Fill>
              <SolidColorBrush Color="{Binding ElementName=colSelector, Path=SelectedColor}" />
            </Rectangle.Fill>
          </Rectangle>
        </StackPanel>
        <StackPanel Orientation="Horizontal" x:Name="_ColorOptionStack">
        </StackPanel>
      </StackPanel>
    </Expander.Header>
    <StackPanel Orientation="Horizontal">

      <StackPanel.Resources>
        <local-util:StringFormatConverter x:Key="sfc" />
      </StackPanel.Resources>

      <Canvas Name="cvSelection" Background="Transparent" Width="110" Height="110" Margin="10">
        <Path Name="coloredPath">
          <Path.OpacityMask>
            <LinearGradientBrush StartPoint="1,0" EndPoint="0,0">
              <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFFFFFFF" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Path.OpacityMask>
          <Path.Data>
            <PathGeometry>
              <PathGeometry.Figures>
                <PathFigure StartPoint="0,0">
                  <LineSegment Point="100,50" />
                  <LineSegment Point="0,100" />
                </PathFigure>
              </PathGeometry.Figures>
            </PathGeometry>
          </Path.Data>
        </Path>

        <Path Name="whitePath" Fill="White">
          <Path.OpacityMask>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0.5,0.66">
              <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFFFFFFF" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Path.OpacityMask>
          <Path.Data>
            <PathGeometry>
              <PathGeometry.Figures>
                <PathFigure StartPoint="0,0">
                  <LineSegment Point="100,50" />
                  <LineSegment Point="0,100" />
                </PathFigure>
              </PathGeometry.Figures>
            </PathGeometry>
          </Path.Data>
        </Path>

        <Path Name="blackPath" Fill="Black">
          <Path.OpacityMask>
            <LinearGradientBrush StartPoint="0,1" EndPoint="0.5,0.33">
              <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFFFFFFF" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Path.OpacityMask>
          <Path.Data>
            <PathGeometry>
              <PathGeometry.Figures>
                <PathFigure StartPoint="0,0">
                  <LineSegment Point="100,50" />
                  <LineSegment Point="0,100" />
                </PathFigure>
              </PathGeometry.Figures>
            </PathGeometry>
          </Path.Data>
        </Path>

        <Path Cursor="Cross" Name="mousePath" Stroke="Black" StrokeThickness="1" Fill="Transparent">
          <Path.Data>
            <PathGeometry>
              <PathGeometry.Figures>
                <PathFigure StartPoint="0,0" IsClosed="True">
                  <LineSegment Point="100,50" />
                  <LineSegment Point="0,100" />
                </PathFigure>
              </PathGeometry.Figures>
            </PathGeometry>
          </Path.Data>
        </Path>

        <Ellipse Name="ellSelecttion" Stroke="Black" StrokeThickness="2" Width="10" Height="10" />
      </Canvas>
      <local:ColorSlider x:Name="colSlider" Minimum="0" Maximum="1"  Margin="0,10,10,5" />

      <Grid Margin="5,0,5,0">
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition />
          <RowDefinition />
          <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition />
          <ColumnDefinition />
          <ColumnDefinition />
          <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <!--HLS textboxes-->
        <TextBlock Style="{StaticResource ProperyTextBlock}" Grid.Column="0" FontSize="13"  Grid.Row="0" Text="H:" />
        <TextBlock Style="{StaticResource ProperyTextBlock}" Grid.Column="0" FontSize="13" Grid.Row="1" Text="L:" />
        <TextBlock Style="{StaticResource ProperyTextBlock}" Grid.Column="0" FontSize="13" Grid.Row="2" Text="S:" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="1" Width="45" Grid.Row="0" Text="{Binding ElementName=colSelector, Path=HlsValue.Hue, Converter={StaticResource sfc}, ConverterParameter=0.00}" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="1" Width="45" Grid.Row="1" Text="{Binding ElementName=colSelector, Path=HlsValue.Lightness, Converter={StaticResource sfc}, ConverterParameter=0.00}" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="1" Width="45" Grid.Row="2" Text="{Binding ElementName=colSelector, Path=HlsValue.Saturation, Converter={StaticResource sfc}, ConverterParameter=0.00}" />

        <!--RGB textboxes-->
        <TextBlock Style="{StaticResource ProperyTextBlock}" Grid.Column="2" FontSize="13"  Grid.Row="0" Text="R:" />
        <TextBlock Style="{StaticResource ProperyTextBlock}" Grid.Column="2" FontSize="13" Grid.Row="1" Text="G:" />
        <TextBlock Style="{StaticResource ProperyTextBlock}" Grid.Column="2" FontSize="13" Grid.Row="2" Text="B:" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="3" Width="45" Grid.Row="0" Text="{Binding ElementName=colSelector, Path=SelectedColorR, Mode=TwoWay}" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="3" Width="45" Grid.Row="1" Text="{Binding ElementName=colSelector, Path=SelectedColorG, Mode=TwoWay}" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="3" Width="45" Grid.Row="2" Text="{Binding ElementName=colSelector, Path=SelectedColorB, Mode=TwoWay}" />

        <!--hex textbox-->
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Column="1" FontSize="13" Grid.Row="3" Grid.ColumnSpan="3"  Text="{Binding ElementName=colSelector, Path=SelectedColor}" />
      </Grid>

      <!--Alpha textbox-->
      <!--BaseColor="{Binding ElementName=colSelector, Path=SelectedColor}"-->
      <!--Value="{Binding ElementName=colSelector, Path=SelectedColorScA, Mode=TwoWay}"-->
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="*" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <local:AlphaSlider HorizontalAlignment="Center"  x:Name="alphaSlider" Grid.Row="0" Minimum="0" Maximum="1"  Margin="0,0,0,5" />
        <TextBox Style="{StaticResource ProperyTextBox}" Grid.Row="1" Width="45" FontSize="13" Text="{Binding ElementName=colSelector, Path=SelectedColorA}" />
      </Grid>
      
    </StackPanel>
  </Expander>
  
  
</UserControl>
